<?php  

$getname = $name;

echo "<script> var test = '".$getname."'</script>";

?>